package com.ship.dispatch.service.fob.impl;
/**
 *@title SpBpmCoordinateServiceImpl
 *@description
 *@author yl
 *@create 2023/12/15 0015
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ship.common.core.web.domain.JsonResult;
import com.ship.common.business.service.impl.BaseServiceImpl;
import com.ship.dispatch.bean.fob.SpBpmCoordinate;
import com.ship.dispatch.mapper.fob.SpBpmCoordinateMapper;
import com.ship.dispatch.service.fob.SpBpmCoordinateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpBpmCoordinateServiceImpl extends BaseServiceImpl<SpBpmCoordinateMapper, SpBpmCoordinate> implements SpBpmCoordinateService {
    @Autowired
    SpBpmCoordinateMapper spBpmCoordinateMapper;
    @Override
    public JsonResult updateXY(SpBpmCoordinate spBpmCoordinate) {
        List<SpBpmCoordinate> list = spBpmCoordinateMapper.selectList(new LambdaQueryWrapper<SpBpmCoordinate>()
                .eq(SpBpmCoordinate::getBpmKey,spBpmCoordinate.getBpmKey())
                .eq(SpBpmCoordinate::getNode,spBpmCoordinate.getNode())
        );
        if(list.size()>0){
            SpBpmCoordinate temp = list.get(0);
            temp.setX(spBpmCoordinate.getX());
            temp.setY(spBpmCoordinate.getY());
            this.updateById(temp);
        }else{
            this.save(spBpmCoordinate);
        }
        return JsonResult.success();
    }
}
